/*订单提交*/
function orderCommit() {
	var remark = $("#remark").val();
	window.location.href = decodeURIComponent(ctx + '/order/orderCommit?remark=' + remark);
}

/*订单新增或修改地址*/
function addUpdateAddress() {
	var errorMsg = $("#error_message");
	var name = $("#name").val();
	var mobile = $("#mobile").val();
	var province = $("#cmbProvince").val();
	var city = $("#cmbCity").val();
	var district = $("#cmbArea").val();
	var detail = $("#detail").val();

	if (name.length == 0) {
		errorMsg.html("收货人姓名不能为空");
		return;
	}
	if (mobile.length == 0) {
		errorMsg.html("收货人手机号不能为空");
		return;
	}
	if (detail.length == 0) {
		errorMsg.html("详细地址不能为空");
		return;
	}

	$.ajax({
				type : 'POST',
				url : ctx + '/address/addUpdateAddress.do',
				data : {
					name : name,
					mobile : mobile,
					province : province,
					city : city,
					district : district,
					detail : detail
				},
				dataType : 'json',
				timeout : 30000,
				context : $('body'),
				success : function(data) {
					$('#myModal').modal('hide')
					if (data.code == "ok") {
						var address = data.object;
						var addressInfo = address.name + "&nbsp"
								+ address.province + "&nbsp" + address.city
								+ "&nbsp" + address.district + "&nbsp"
								+ address.detail + "&nbsp" + address.mobile
								+ "&nbsp";
						var editHtml = '<a href="javascript:;" class="label label-success" data-toggle="modal" data-target="#myModal">修改</a>';
						$("#address_info").html(addressInfo + editHtml);
					} else {
						errorMsg.html(data.msg);
					}
				},
				error : function(xhr, type) {
					errorMsg.html('提交失败!');
				}
			});
}